package com.xtxk.utils.util;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * 将对象转成Map
 */
public class MapHelperUtil {
	
	public  static Map<String,Object>  objectToMap(Object object) throws IllegalAccessException {
		Map<String,Object> map = new HashMap<String,Object>();
		Class<?> clazz = object.getClass();
		for(Field field : clazz.getDeclaredFields()) {
			field.setAccessible(true);
			String fieldName=""+field.getName().toUpperCase()+"";
			Object value =field.get(object);
			map.put(fieldName, value);
		}
		return map;
	}
	
	public  static Map<String,Object>  objectToMapInfo(Object object) throws IllegalAccessException {
		Map<String,Object> map = new HashMap<String,Object>();
		Class<?> clazz = object.getClass();
		for(Field field : clazz.getDeclaredFields()) {
			field.setAccessible(true);
			String fieldName=field.getName().toUpperCase();
			Object value =field.get(object);
			map.put(fieldName, value);
		}
		return map;
	}
	

}
